import { createRouter, createWebHashHistory } from 'vue-router'
import IndexView from '../views/IndexView.vue';
import projectTableView from '../views/leader/project/projectTable/projectTableView.vue';
import CalendarView from '../views/leader/CalendarView.vue'
import CalendarUpdateView from '../views/leader/CalendarUpdateView.vue'
import CompanyIndexView from '@/views/leader/CompanyIndexView.vue'
import MemberIndexView from '@/views/member/MemberIndexView.vue'
import MinisterIndexView from '@/views/minister/MinisterIndexView'
import AcceptProjectView from '@/views/minister/taskSetting/AcceptProjectView'
import AmendTaskView from '@/views/minister/taskSetting/AmendTaskView'
import CheckTaskView from '@/views/minister/taskSetting/CheckTaskView.vue'
import TaskDetailView from '@/views/minister/taskSetting/TaskDetailView'
import ReflectView from '@/views/minister/taskSetting/ReflectView'
import MinisterTaskAssignView from "@/views/minister/taskSetting/MinisterTaskAssignView";
import ReleaseProjectView from '@/views/leader/project/release/ReleaseProjectView.vue'
import AddDepartmentView from '@/views/leader/maintain/department/AddView.vue'
import EditDepartmentView from '@/views/leader/maintain/department/EditView.vue'
import Context from "@/views/manage/Context";
import ConfigContext from "@/views/manage/ConfigContext";
//import Paging from "@/views/manage/Paging";
import Homepage from "@/views/manage/Homepage";
import MenuContext from "@/views/manage/MenuContext";
import UserLoginView from '@/views/UserLoginView.vue'
import UserRegisterView from '@/views/UserRegisterView'
import EditProjectView from "@/views/leader/project/edit/EditProjectView.vue";
import DistributionView from "@/views/leader/maintain/personnel/DistributionView.vue";
import EditPositionView from "@/views/leader/maintain/position/EditPositionView.vue";
import PersonalIndexView from "@/views/personal/PersonalIndexView.vue";
import MaintainView from "@/views/leader/maintain/account/MaintainView.vue";
import CreateCompanyView from "@/views/personal/CreateCompanyView.vue";
import JoinCompanyView from '@/views/personal/JoinCompanyView'
import scheule from '@/components/schedule/scheule.vue'
import MemberCalendarView from '../views/member/MemberCalendarView.vue'
import MinisterCalendarView from '../views/minister/MinisterCalendarView.vue'
import MemberCalendarUpdateView from '../views/member/MemberCalendarUpdateView.vue'
import MinisterCalendarUpdateView from '../views/minister/MinisterCalendarUpdateView.vue'
import PersonalCalendarView from '../views/personal/PersonalCalendarView.vue'
import PersonalUpdateCalendarView from '../views/personal/PersonalUpdateCalendarView.vue'
import MemListView from '../views/member/company/MemListView.vue'
import MemberFeedback from '../views/member/company/MemberFeedback.vue'
import MemberButton from '../views/member/company/MemberButton.vue'
import ApplyView from "@/views/leader/maintain/personnel/ApplyView.vue";
import ManageLogin from "@/views/manage/ManageLogin";
import MemberTaskStatus from '../views/member/company/MemberTaskStatus.vue'
import MemberPosition from '../views/member/company/MemberPosition.vue'
import DepartmentInformation from '../views/member/company/DepartmentInformation.vue'
import MemberCompanyFeedback from '../views/member/company/MemberCompanyFeedback.vue'
import MemberCompanyButton from '../views/member/company/MemberCompanyButton.vue'
import EditUserView from '@/views/UserCenter/EditUserView.vue'
const routes = [
  {
    path:'/MemberCompanyButton',
    name:'MemberCompanyButton',
    component:MemberCompanyButton
  },
  {
    path:'/MemberCompanyFeedback',
    name:'MemberCompanyFeedback',
    component:MemberCompanyFeedback
  },
  {
    path:'/DepartmentInformation',
    name:'DepartmentInformation',
    component:DepartmentInformation
  },
  {
    path:'/MemberPosition',
    name:'MemberPosition',
    component:MemberPosition
  },
  {
    path:'/MemberTaskStatus',
    name:'MemberTaskStatus',
    component:MemberTaskStatus
  },
  {
    path:'/MemListView',
    name:'MemListView',
    component:MemListView
  },
  {
    path:'/MemberButton',
    name:'MemberButton',
    component:MemberButton
  },
  {
    path:'/MemberFeedback',
    name:'MemberFeedback',
    component:MemberFeedback
  },
  {
    path: '/',
    redirect:"/IndexView"
    // component: IndexView
  },
  {
    path:'/IndexView',
    name:'IndexView',
    component:IndexView
  },
  {
    path:'/PersonalIndexView',
    name:'PersonalIndexView',
    component:PersonalIndexView
  },
  {
    path:'/PersonalCalendarView',
    name:'PersonalCalendarView',
    component:PersonalCalendarView
  },
  {
    path:'/PersonalUpdateCalendarView',
    name:'PersonalUpdateCalendarView',
    component:PersonalUpdateCalendarView
  },
  {
   path:'/MinisterCalendarUpdateView',
   name:'MinisterCalendarUpdateView',
   component:MinisterCalendarUpdateView
  },
  /**
   *  老板功能  ：
   *             1. 企业架构 maintain
   *                    /AddView   /EditView
   *                    /ApplyView  /DistributionView
   *                    /EditPositionView   /MaintainView
   * 
   *             2. 项目功能 project
   *                    /ReleaseProjectView     /projectTableView
   *                    /EditProjectView
   *                    
   */
  {
    path:'/AddDepartmentView',
    name:'AddDepartmentView',
    component:AddDepartmentView
  },{
    path:'/CompanyIndexView',
    name:'CompanyIndexView',
    component:CompanyIndexView
  },{
    path:'/projectTableView',
    name:'projectTableView',
    component:projectTableView
  },
  {
    path:'/ReleaseProjectView',
    name:'ReleaseProjectView',
    component:ReleaseProjectView
  },
  {
    path:'/EditDepartmentView',
    name:'EditDepartmentView',
    component:EditDepartmentView
  },
  {
    path:'/EditProjectView',
    name:'EditProjectView',
    component:EditProjectView
  },{
    path:'/ApplyView',
    name:'ApplyView',
    component:ApplyView
  },{
    path:'/DistributionView',
    name:'DistributionView',
    component:DistributionView
  },{
    path:'/EditPositionView',
    name:'EditPositionView',
    component:EditPositionView
  },{
    path:'/MaintainView',
    name:'MaintainView',
    component:MaintainView
  },


  {
    path:'/MemberIndexView',
    name:'MemberIndexView',
    component:MemberIndexView
  },
  {
    path:'/MinisterIndexView',
    name:'MinisterIndexView',
    component:MinisterIndexView
  },
  {
    path:'/MinisterCalendarView',
    name:'MinisterCalendarView',
    component:MinisterCalendarView
  },
  {
    path:'/CalendarView',
    name:'CalendarView',
    component:CalendarView
  },
  {
    path:"/CalendarUpdateView",
    name:'CalendarUpdateView',
    component:CalendarUpdateView
  },
  {
    path:'/MemberCalendarView',
    name:'MemberCalendarView',
    component:MemberCalendarView
  },
  {
    path:"/MemberCalendarUpdateView",
    name:'MemberCalendarUpdateView',
    component:MemberCalendarUpdateView,
  },
  {
    path:"/scheule",
    name:'scheule',
    component:scheule
  },

  /**
   *  部长功能  ：
   *             1. 任务设置 taskSetting
   *             2. 信息修改 infoSetting
   *             3. 企业架构 architecture
   *             4.退出 logout
   */
  // 4 退出
  //任务审核...
  {
    path:'/Minister/Check',
    name:'CheckTaskView ',
    component:CheckTaskView,
    // component: () =>import('../views/minister/taskSetting/CheckTaskView.vue')

  },
  {
    path: '/ministerLogout',
    name:'MinisterLogout',
    component: ()=>import('../views/minister/architecture/MinisterLogoutView')
  },
  //  3 企业架构
  {
    path:'/architecture',
    name:'Architecture',
    component: () =>import('../views/minister/architecture/UserListView')
  },
  //  1 任务设置
  //单独分配任务
  {
    path:'/MinisterTaskAssignView',
    name:'MinisterTaskAssignView ',
    // component: () => import('../views/minister/architecture/MinisterTaskAssignView.vue')
    component:MinisterTaskAssignView,
  },
  //提交申请
  {
    path: '/SubmitProject',
    name:'SubmitProject',
    component: () => import('../views/minister/taskSetting/SubmitProjectView')
  },
  //接收项目并分配
  {
    path:'/AcceptProjectView',
    name:'AcceptProjectView',
    component:AcceptProjectView
  },
  //修改任务（X）
  {
    path:'/AmendTaskView ',
    name:'AmendTaskView ',
    component:AmendTaskView
  },
  //任务完成明细（X）
  {
    path:'/TaskDetailView ',
    name:'TaskDetailView ',
    component:TaskDetailView
  },
  //查看驳回项目
  {
    path:'/reflect',
    name:'ReflectView ',
    component:ReflectView,
  },
  //--------------------------------------
  {
    path: '/ManageLogin',
    name: 'ManageLogin',
    component: ManageLogin
  },
  {
    path: "/context",
    name: "context",
    component: Context
  },
  // {
  //   path: "/paging",
  //   name: "paging",
  //   component: Paging
  // },
  {
    path: "/homepage",
    name: "homepage",
    component: Homepage
  },
  // {
  //   path: "/managelogin",
  //   name: "managelogin",
  //   component: ManageLogin
  // },
  {
    path: "/MenuContext",
    name: "MenuContext",
    component: MenuContext
  },
  /**
  *  登录功能  ：
  *             1. 任务设置 taskSetting
  *                    
  */
  {
    path: "/UserLoginView",
    name: "UserLoginView",
    component: UserLoginView
  },
  /* 
  注册功能
  */
  {
    path: "/UserRegisterView",
    name: "UserRegisterView",
    component: UserRegisterView
  },
  /*
  创建公司
  */
  {
    path: "/CreateCompanyView",
    name: "CreateCompanyView",
    component: CreateCompanyView
  },
  /* 
  加入公司
  */
 {
   path: "/JoinCompanyView",
   name: "JoinCompanyView",
   component: JoinCompanyView
 },
 /* 
 用户修改页面
 */
{
  path: "/EditUserView",
  name: "EditUserView",
  component: EditUserView
}

]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})
//路由守卫导航守卫
router.beforeEach((to,from,next)=>{
      //验证token中是否有数据
      let token = localStorage.getItem("token");
      if(!token&&to.path == "/context"){
        next("/ManageLogin")
      }
      else if (!token&&to.path == "/homepage"){
        next("/ManageLogin")
      }
      else if (!token&&to.path == "/MenuContext"){
        next("/ManageLogin")
      }
      else {
        next()
      }
    }
)
export default router
